<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<script type="text/javascript">
$(function() {
    parent.$.messager.progress('close');

    $('#form').form({
        url : contextPath+"/crmcustomer/editCrmCustomer.action",
        onSubmit : function() {
            parent.$.messager.progress({
            	title : var_alert_title,
                text : var_data_processing
            });
            //检查Form参数合法性,返回false不提交
           if(!checkForm()){
               parent.$.messager.progress('close');
                return false;
            }
        },
        success : function(data) {
            parent.$.messager.progress('close');
            data = JSON.parse(data);
            if(data && "success" == data.result){
           	 parent.$.messager.alert(var_alert_title, data.msg, 'info');
           	 parent.$.modalDialog.handler.dialog('close');
          	     parent.$.modalDialog.openner_dataGrid.datagrid('reload');
            } else {
                parent.$.messager.alert(var_common_error, data.msg, 'error');
            }
        }
    });
});

function checkForm(){
	var isValid = true;
	var checkCrmCustomerUrl = contextPath + "/crmcustomer/checkCrmCustomer.action";
	
	var postNum = $("#form").find("[name='cusNameEn']").validatebox({
	    required: true,
		validType:['length[1,30]','remoteValid[\''+checkCrmCustomerUrl+'\',\'cusNameEn\',\'<s:text name="erp.business.crm.customer.isexisted"></s:text>\',\'${crmCustomer.cusNameEn }\']']
	});
	isValid = isValid && postNum.validatebox('isValid');
	
	var postName = $("#form").find("[name='cusNameZh']").validatebox({
	    required: true
	});
	isValid = isValid && postName.validatebox('isValid');

	//var email = $("#form").find("[name='email']").validatebox({
		//validType:'email'
	//});
	//isValid = isValid && email.validatebox('isValid');
	
	return isValid;
}
</script>
<!-- edit-dialog begin -->
<div class="edit-param-context">
   <div class="p5">
            <form id="form" name="form" action="" method="post">
                <table class="tablewidth1">
                	<tr>
                		<td align="right">
                			<s:text name="erp.business.crm.crmcustomer.cusnameen"></s:text>：
                		</td>
                		<td align="left">
                			<input id="id" name="id" type="hidden" value="${crmCustomer.id}"/>
                			<input id="cusNameEn" name="cusNameEn" class="span2" type="text" value="${crmCustomer.cusNameEn }" style="width: 480px;"/>
                		</td>
                	</tr>
                	<tr>
                		<td align="right">
                			<s:text name="erp.business.crm.crmcustomer.cusnamezh"></s:text>：
                		</td>
                		<td align="left">
                			<input id="cusNameZh" name="cusNameZh" class="span2"  type="text" value="${crmCustomer.cusNameZh }" style="width: 480px;"/>
                		</td>
                	</tr>
                	<tr>
                		<td align="right">
                			<s:text name="erp.business.crm.crmcustomer.address"></s:text>：
                		</td>
                		<td align="left">
                			<input id="address" name="address" class="span2"  type="text" value="${crmCustomer.address }" style="width: 480px;"/>
                		</td>
                	</tr>
                	<tr>
                		<td align="right">
                			<s:text name="erp.business.crm.crmcustomer.telfax"></s:text>：
                		</td>
                		<td align="left">
                			<input id="telFax" name="telFax" class="span2"  type="text" value="${crmCustomer.telFax }" style="width: 480px;"/>
                		</td>
                	</tr>
                	<tr>
                		<td align="right">
                			<s:text name="erp.business.crm.crmcustomer.email"></s:text>：
                		</td>
                		<td align="left">
                			<input id="email" name="email" class="span2"  type="text" style="width: 480px;" value="${crmCustomer.email }"/>
                		</td>
                	</tr>
                	<tr>
	        			<td align="right">
	        				<s:text name="erp.description"></s:text>：
	        			</td>
	        			<td>
	        				<textarea id="description" name="description" class="" style="height: 80px;overflow: auto;line-height: 18px;width: 480px;">${crmCustomer.description }</textarea>
	        			</td>
        			</tr>
                </table>
               
                <div class="fn-clear"></div>
            </form>
        </div>
</div> 